﻿@using EIP.Common.Entities.Dtos
@using EIP.Web.AdminLTE.DataUsers.Helpers
@{
    ViewBag.Title = "首页";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<form id="editform" method="POST" name="editform" class="form-horizontal">
    <div class="row">
        <div class="col-md-12">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#base" data-toggle="tab" aria-expanded="true">基础配置</a>
                    </li>
                    <li class="">
                        <a href="#log" data-toggle="tab" aria-expanded="false">日志配置</a>
                    </li>
                    <li class="pull-right header"><i class="fa fa-inbox"></i> 系统参数配置项</li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="base">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h4 class="box-title">登录配置</h4>
                                        <div class="box-tools pull-right">
                                            <button type="button" class="btn btn-danger fa" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="伸缩">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="box-body form-horizontal bv-form fv-form fv-form-bootstrap">
                                        <div class="col-md-12">
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">登录界面标题：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "2ac2f924-787c-4fb2-b27d-f7f659fe94b1",
                                Placeholder = "请输入登录界面标题",
                                Required = true,
                                NotemptyMessage = "请输入登录界面标题"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">登录界面logo地址：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "f79a849f-0f49-4483-9b24-5399090188f3",
                                Placeholder = "请输入登录界面logo地址",
                                Required = true,
                                NotemptyMessage = "请输入登录界面logo地址"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">同时登录一个帐号：</label>
                                                <div class="input-group col-sm-10">
                                                    <label>
                                                        @Html.CheckBoxHtmlString(new CheckBoxInput
                    {
                        Name = "11203027-bad9-4bc2-92f2-2da0e5361055",
                        Title = "同时登录一个帐号"
                    })

                                                    </label>

                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">登录地址底部描述：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "7295f6ce-1ddb-4e89-8626-58a16e253e14",
                                Placeholder = "请输入登录地址底部描述",
                                Required = true,
                                NotemptyMessage = "请输入登录地址底部描述"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">登录界面提示语句：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "b1eff77a-a8ba-492d-bbd6-21f353c5719d",
                                Placeholder = "请输入登录界面提示语句",
                                Required = true,
                                NotemptyMessage = "请输入登录界面提示语句"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">密码记住时间(天)：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "8553d000-02b5-4e34-9578-45839fc59aa4",
                                Placeholder = "请输入密码记住时间(天)",
                                Required = true,
                                NotemptyMessage = "请输入密码记住时间(天)"
                            })
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h4 class="box-title">系统首页</h4>
                                        <div class="box-tools pull-right">
                                            <button type="button" class="btn btn-danger fa" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="伸缩">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="box-body form-horizontal bv-form fv-form fv-form-bootstrap">
                                        <div class="col-md-12">
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">系统标题：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "126979e7-b17b-4ff1-b9ad-7cf77e9598b9",
                                Placeholder = "请输入系统标题",
                                Required = true,
                                NotemptyMessage = "请输入系统标题"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">系统版本号：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "56a4da5b-1301-43bd-a1cf-ae25edc28398",
                                Placeholder = "请输入系统版本号",
                                Required = true,
                                NotemptyMessage = "请输入系统版本号"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">缓存实例值：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "3641e0e6-ce8b-40f3-b83a-51bf528766a7",
                                Placeholder = "请输入缓存实例值",
                                Required = true,
                                NotemptyMessage = "请输入缓存实例值"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">技术支持：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "73e26cff-7a91-47b7-8b4b-d84241a951a3",
                                Placeholder = "请输入技术支持",
                                Required = true,
                                NotemptyMessage = "请输入技术支持"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">问题反馈：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "eb667561-8c67-4502-8776-cf3c620d0d56",
                                Placeholder = "请输入问题反馈",
                                Required = true,
                                NotemptyMessage = "请输入问题反馈"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">CopyRight：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "85dd5058-bc9f-426f-93c3-68ed8d8e451c",
                                Placeholder = "请输入CopyRight",
                                Required = true,
                                NotemptyMessage = "请输入CopyRight"
                            })
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h4 class="box-title">密码</h4>
                                        <div class="box-tools pull-right">
                                            <button type="button" class="btn btn-danger fa" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="伸缩">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="box-body form-horizontal bv-form fv-form fv-form-bootstrap">
                                        <div class="col-md-12">
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">登录密码Key：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "f03312ad-386f-4a2a-9700-133f1b0f61cf",
                                Placeholder = "请输入登录密码Key",
                                Required = true,
                                NotemptyMessage = "请输入登录密码Key"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">重置密码值：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "80f04cab-92aa-4080-b149-99e197105bde",
                                Placeholder = "请输入重置密码值",
                                Required = true,
                                NotemptyMessage = "请输入重置密码值"
                            })
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h4 class="box-title">错误邮件提示设置</h4>
                                        <div class="box-tools pull-right">
                                            <button type="button" class="btn btn-danger fa" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="伸缩">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="box-body form-horizontal bv-form fv-form fv-form-bootstrap">
                                        <div class="col-md-12">
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">发生错误发送邮件：</label>
                                                <div class="input-group col-sm-10">
                                                    <label>
                                                        @Html.CheckBoxHtmlString(new CheckBoxInput
                    {
                        Name = "ae5ab5aa-700f-4ac6-9290-08a3c4f1425f",
                        Title = "发生错误发送邮件"
                    })
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">发送邮箱账号：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "9572fec2-0522-45b7-ae1f-0384f6cab841",
                                Placeholder = "请输入发送邮箱账号",
                                Required = true,
                                NotemptyMessage = "请输入发送邮箱账号"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">发送邮箱密码：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                            {
                                Name = "891f6f0d-22db-4308-bcce-ab46c4edad4b",
                                Placeholder = "请输入发送邮箱密码",
                                Required = true,
                                NotemptyMessage = "请输入发送邮箱密码"
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">接收邮箱SMTP：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.DropDownListEmailServer(new DropDownListDictionaryInput
                            {
                                Id = "ab890271-5baa-47a6-afcd-233ddcb335dd",
                                Name = "ab890271-5baa-47a6-afcd-233ddcb335dd",
                                NeedDefault = false,
                                HtmlAttributes = new { @class = "form-control select2", style = "width: 100%;" }
                            })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">使用SSL：</label>
                                                <div class="input-group col-sm-10">
                                                    <label>
                                                        @Html.CheckBoxHtmlString(new CheckBoxInput
                    {
                        Name = "d1740b06-0d4e-4258-a187-4ac10f2e0624",
                        Title = "使用SSL"
                    })
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane" id="log">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h4 class="box-title">日志配置</h4>
                                        <div class="box-tools pull-right">
                                            <button type="button" class="btn btn-danger fa" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="伸缩">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="box-body form-horizontal bv-form fv-form fv-form-bootstrap">
                                        <div class="col-md-12">
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">文本文件地址：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                                    {
                                        Name = "414d3131-7a2b-4568-8f72-816fd704d0e4",
                                        Placeholder = "请输入文本文件地址",
                                        Required = true,
                                        NotemptyMessage = "请输入文本文件地址"
                                    })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">导出缓存地址：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapText(new BootstrapBoxInput
                                    {
                                        Name = "3844fc35-68e9-4b1d-ae9d-bd5f3d0299ad",
                                        Placeholder = "请输入导出缓存地址",
                                        Required = true,
                                        NotemptyMessage = "请输入导出缓存地址"
                                    })
                                                </div>
                                            </div>
                                            <div class="form-group has-feedback">
                                                <label class="col-sm-2 control-label">Log4net配置值：</label>
                                                <div class="input-group col-sm-10">
                                                    @Html.BootstrapTextArea(new BootstrapBoxInput
                                    {
                                        Name = "27332a9f-aae6-41fd-8432-eb212ab1de03",
                                        Placeholder = "请输入Log4net配置值",
                                        Required = true,
                                        NotemptyMessage = "请输入Log4net配置值",
                                        HtmlAttributes = " style='height:268px'"
                                    })
                                                </div>
                                            </div>

                                        </div>

                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer text-right">
                <!--以下两种方式提交验证,根据所需选择-->
                <button type="submit" class="btn btn-success" data-btn-type="save" title="确定"><span class="bootstrap-dialog-button-icon fa fa-check"></span>确定</button>
            </div>
        </div>
    </div>
</form>
<script>
    $(function () {
        initControl();
        initData();
        initForm();
    });

    //初始化控件
    function initControl() {
        //基础使用方法
        $("input").iCheck({
            labelHover: false,
            cursor: true,
            checkboxClass: "icheckbox_square-blue",
            radioClass: "iradio_square-blue",
            increaseArea: "20%"
        });
        //初始化控件
        $(".select2").select2();
    }

    var form = null;
    //初始化表单
    function initForm() {
        //初始化控件
        form = $("#editform").form();
        //数据校验
        $("#editform").formValidation({
            message: '请输入有效值',
            trigger: 'blur',
            fields: {

            }
        }).on('success.form.fv', function (e) {

            var json = "";
            $("#editform").find('input[name], select[name], textarea[name]').not(':file').each(function (i, item) {
                if (item.type === "checkbox") {
                    json += "{\"C\":\"" + item.name + "\",\"V\":\"" + escape(item.checked) + "\"},";
                } else {
                    json += "{\"C\":\"" + item.name + "\",\"V\":\"" + escape(item.value) + "\"},";
                }
            });

            json = json.substring(0, json.length - 1);
            json = "[" + json + "]";
            console.log(json);
            UtilAjaxPostWait("/System/Config/SaveConfig", { value: json }, function (data) {
                if (DialogAjaxResult(data)) { }
            });
            return false;
        });
    }

    //初始化数据
    function initData() {
        //初始化控件
        UtilAjaxPostWait("/System/Config/GetConfig", {}, function (data) {
            $.each(data, function (i, item) {
                if (item.C === "11203027-bad9-4bc2-92f2-2da0e5361055") {
                    if (item.V === "true") {
                        $("input[type=checkbox][name='11203027-bad9-4bc2-92f2-2da0e5361055']").iCheck('check');
                    }
                }
                else if (item.C === "ae5ab5aa-700f-4ac6-9290-08a3c4f1425f") {
                    if (item.V === "true") {
                        $("input[type=checkbox][name='ae5ab5aa-700f-4ac6-9290-08a3c4f1425f']").iCheck('check');
                    }
                }
                else if (item.C === "d1740b06-0d4e-4258-a187-4ac10f2e0624") {
                    if (item.V === "true") {
                        $("input[type=checkbox][name='d1740b06-0d4e-4258-a187-4ac10f2e0624']").iCheck('check');
                    }
                }
                else {
                    $("[name='" + item.C + "']").val(item.V);
                }
            });

        });
    }
</script>